<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <style>
        #header{
            background-color: #FCFCFC;
        }
        .btn-box{
            width: 56px;
            height: 48px;
        }
        .btn-back{
            width: 40px;
            margin-left: 1em;
            background: url(../image/back_normal.png) center center no-repeat;
            background-size: 100%;
            padding-top: 0;
        }
        .btn-box img{
            margin: 0 auto;
            width: 40px;
            display: block;
            padding-top: 4px;
        }
        .btn-box:active{
            background-color: #82D0ED;
        }
        .btn-back:active{
            background:#82D0ED url(../image/back_hover.png) center center no-repeat;
            background-size: 100%;
        }
        #header .title{
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            font-size: 1.1em;
            line-height: 48px;
            color: #585858;
            text-align: left;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }
        #header .header-content{
            border-bottom: 1px solid #BABABA;
        }
    </style>
</head>
<body ontouchstart="">
    <div id="wrap">
        <div id="header">
            <div class="header-content clearfix">
                <div class="btn-box btn-back" tapmode onclick="backOrClose();"></div>
                <h5 class="title">&nbsp;</h5>
                <div class="btn-box" tapmode onclick="api.closeWin();">
                    <img src="../image/webview_close.png" alt="">
                </div>
                <div class="btn-box" tapmode onclick="">
                    <img src="../image/more_normal.png" alt="">
                </div>
            </div>
        </div>
        <div id="main">
                
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
    var backOrClose = function(){
        // 在安卓上if(history.back())有问题，总是执行closeWin();
        var str = 'if (history.back()) {history.go(-1);} else{if(api){api.closeWin();}}';

        api.execScript({
            frameName: 'webframe',
            script: str
        });
    };
    var openFrameFn = function(){
        api.openFrame({
            name: 'webframe',
            url: curUrl,
            bounces: false,
            rect: {
                x: 0,
                y: headerPos.h,
                w: 'auto',
                h: mainPos.h
            }
        });  
    };
    apiready = function(){
        var title = api.pageParam.title;
        var url = api.pageParam.url;
        var frameName = api.pageParam.frameName;

        
        //console.log(typeof api.pageParam)
        //var httpUrl = api.pageParam["httpUrl"];

        var header = $api.byId('header');
        $api.fixIos7Bar(header); 
        window.headerPos = $api.offset(header);
        var main = $api.byId('main');
        window.mainPos = $api.offset(main);
        
        window.curUrl = url;
        if (frameName) {
            curUrl = frameName+'.html';
        }
        $api.dom('#header .title').innerHTML = title;
        openFrameFn();
    };
</script>
</html>